<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" scroll="no">
<%@ taglib prefix="ef" uri="control"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>组织层级</title>
<link rel="shortcut icon" href="${res}favicon.ico" type="image/x-icon" />
 <!--Basic Styles-->
<link href="../framework/css/font.css" rel="stylesheet" />
<link href="../framework/miniui/themes/material/miniui.css" rel="stylesheet" />
<link href="../framework/css/app.min.1.css" rel="stylesheet" type="text/css" />
<link href="../framework/css/app.min.2.css" rel="stylesheet" type="text/css" />
<script src="../framework/main.js" type="text/javascript"></script>
<style type="text/css">
    html, body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }    
    </style>
</head>
<body class="body-detail">
<script>
	Page.onLoad(function(){
		mini.get('dg1').load();	
	});
	
	function addOrgLevel(){
		var diag = mini.open({
			width: 600,
			height : 300,
			title : "添加组织层级",
			showMaxButton: true,
			url : "${ctx}mhr/orgLevelDialog.jhtml",
			onLoad : function(){
			},
			onOk : save
		});
	}
	
	function save(){
		var form = $DW.mini.getForm('form2');
		form.validate();
		if(form.isValid() == false){
			return;
		}
		Server.sendRequest("OrgLevel.save",form.getData(),function(response){
			if(response.Status == 1){
				top.mini.showTips({content:response.Message,state:'success'});
				$D.close();
				mini.get('dg1').clearSelect();
				mini.get('dg1').reload();
			}else{
				top.mini.warn(response.Message);
			}
		});
	}
	
	function editOrgLevel(){
		var row = mini.get('dg1').getSelected();
		if(!row){
			top.mini.alert("@{Framework.DataGrid.PleaseSelectFirst}");
			return;
		}
		var id = row.ID;
		var diag = mini.open({
			width: 600,
			height : 300,
			title : "编辑组织层级",
			showMaxButton: true,
			url : "${ctx}mhr/orgLevelDialog.jhtml?ID="+id,
			onLoad : function(){
			},
			onOk : save
		});
	}
	
	function delOrgLevel() {
		var arr = mini.get('dg1').getSelectedValue();
		if(!arr||arr.length==0){
			top.mini.alert("@{Common.PleaseSelectToDeleteRowFirst}");
			return;
		}
		top.mini.confirm("确认要删除组织层级？",function(action){
			if(action == "ok"){
				Server.sendRequest("OrgLevel.del", {IDs:arr.join()},function(response){
					if(response.Status == 1){
						top.mini.showTips({content:response.Message,state:'success'});
						mini.get('dg1').reload();
					}else{
						top.mini.warn(response.Message);
					}
				});
			}
		});
	}
</script>

<div class="mini-toolbar" style="margin:2px 10px;" id="toolbar1" plain="true">
     <a id="addBtn" class="mini-button" iconCls="icon-add" onClick="addOrgLevel()" plain="true">添加</a>
     <a id="addBtn" class="mini-button" iconCls="icon-edit" onClick="editOrgLevel()" plain="true">编辑</a>
     <a id="removeBtn" class="mini-button" iconCls="icon-remove" onClick="delOrgLevel()" plain="true">删除</a>
</div>

<div class="mini-fit" style="padding:0 10px 10px 10px;">
	<div id="dg1" class="mini-datagrid z-depth-1" style="width:100%;height:100%;" method="OrgLevel.grid" idField="ID" multiSelect="true">
	    <div property="columns">
	       	<div type="indexcolumn"></div>
	        <div type="checkcolumn" ></div>        
            <div field="Level" width="13%">级别</div>
            <div field="Name" width="12%">名称</div>
	    </div>
	</div>
</div>
</body>
</html>